import { defineStore } from "pinia"
import {getHomeHotSuggests,getHomeCategories,getHomeHouselist} from '@/services'
const useHomeStore = defineStore("home", {
	state: () => ({
		hotSuggests: [],
		categories: [],
		currentPage:1,
		houselist:[],
	}),
	actions: {
		async fetchHotSuggestsData() {
			const res = await getHomeHotSuggests()
			this.hotSuggests = res.data
		},
		async fetchCategoriesData() {
			const res = await getHomeCategories()
			this.categories = res.data
		},
		async fetchHouseListData() {
			const res = await getHomeHouselist(this.currentPage)
			this.houselist.push(...res.data)
			this.currentPage++
		}
	}
})
export default useHomeStore
